<?php
/**
 * 注：此模板为自动生成模板，需要根据实际情况调整修改
 * 此模板对 无主键/单一主键 表的支持较好，联合主键表在下一版本开发
 */
namespace Data;

use Utils\MyException;

class Food {

    //数组
    private $array;


    public function __construct ($array){

        $this->array = $array;

        self::setDefault();

    }

    public function getArray() {
        return $this->array;
    }

    public function updateWithArray($array) {
        foreach($array as $key=>$value)
        {
            if(array_key_exists($key,$this->array))
            {
                $this->array = array_merge($this->array,array($key=>$value));
            }
        }
    }



    private function setDefault(){

        if(count($this->array)==0){
            self::setFOOD_ID("null");
            self::setRESTAURANT_ID("0");
            self::setFOOD_GROUP_ID("0");
            self::setFOOD_NAME("");
            self::setIMG_URL("");
            self::setFOOD_PRICE("0");
            self::setIS_LIMIT("0");
            self::setLUNCHBOX_AMOUNTS("0");
            self::setLUNCHBOX_PRICE("0");
            self::setIS_ON_SELL("0");
            self::setSTOCK_DAY("0");
            self::setSTOCK_LEFT("0");
            self::setSPECIAL_FEATURE("0");
            self::setORDER_UNIT("");
            self::setORDER_MINIMUM("0");
            self::setFOOD_TAG_ID("");
            self::setDESCRIPTION("");
            self::setDISPLAY_ORDER("0");
            self::setCREATED_ON("");
            self::setCREATED_BY("0");
            self::setUPDATED_ON("");
            self::setUPDATED_BY("0");

        }
    }






    public function setFOOD_ID($value) {
        $this->array = array_merge ($this->array,array(
            'FOOD_ID' => $value));
    }
    public function getFOOD_ID(){

        return $this->array ['FOOD_ID'];
    }


    public function setRESTAURANT_ID($value) {
        $this->array = array_merge ($this->array,array(
            'RESTAURANT_ID' => $value));
    }
    public function getRESTAURANT_ID(){

        return $this->array ['RESTAURANT_ID'];
    }


    public function setFOOD_GROUP_ID($value) {
        $this->array = array_merge ($this->array,array(
            'FOOD_GROUP_ID' => $value));
    }
    public function getFOOD_GROUP_ID(){

        return $this->array ['FOOD_GROUP_ID'];
    }


    public function setFOOD_NAME($value) {
        $this->array = array_merge ($this->array,array(
            'FOOD_NAME' => $value));
    }
    public function getFOOD_NAME(){

        return $this->array ['FOOD_NAME'];
    }


    public function setIMG_URL($value) {
        $this->array = array_merge ($this->array,array(
            'IMG_URL' => $value));
    }
    public function getIMG_URL(){

        return $this->array ['IMG_URL'];
    }


    public function setFOOD_PRICE($value) {
        $this->array = array_merge ($this->array,array(
            'FOOD_PRICE' => $value));
    }
    public function getFOOD_PRICE(){

        return $this->array ['FOOD_PRICE'];
    }


    public function setIS_LIMIT($value) {
        $this->array = array_merge ($this->array,array(
            'IS_LIMIT' => $value));
    }
    public function getIS_LIMIT(){

        return $this->array ['IS_LIMIT'];
    }


    public function setLUNCHBOX_AMOUNTS($value) {
        $this->array = array_merge ($this->array,array(
            'LUNCHBOX_AMOUNTS' => $value));
    }
    public function getLUNCHBOX_AMOUNTS(){

        return $this->array ['LUNCHBOX_AMOUNTS'];
    }


    public function setLUNCHBOX_PRICE($value) {
        $this->array = array_merge ($this->array,array(
            'LUNCHBOX_PRICE' => $value));
    }
    public function getLUNCHBOX_PRICE(){

        return $this->array ['LUNCHBOX_PRICE'];
    }


    public function setIS_ON_SELL($value) {
        $this->array = array_merge ($this->array,array(
            'IS_ON_SELL' => $value));
    }
    public function getIS_ON_SELL(){

        return $this->array ['IS_ON_SELL'];
    }


    public function setSTOCK_DAY($value) {
        $this->array = array_merge ($this->array,array(
            'STOCK_DAY' => $value));
    }
    public function getSTOCK_DAY(){

        return $this->array ['STOCK_DAY'];
    }


    public function setSTOCK_LEFT($value) {
        $this->array = array_merge ($this->array,array(
            'STOCK_LEFT' => $value));
    }
    public function getSTOCK_LEFT(){

        return $this->array ['STOCK_LEFT'];
    }


    public function setSPECIAL_FEATURE($value) {
        $this->array = array_merge ($this->array,array(
            'SPECIAL_FEATURE' => $value));
    }
    public function getSPECIAL_FEATURE(){

        return $this->array ['SPECIAL_FEATURE'];
    }


    public function setORDER_UNIT($value) {
        $this->array = array_merge ($this->array,array(
            'ORDER_UNIT' => $value));
    }
    public function getORDER_UNIT(){

        return $this->array ['ORDER_UNIT'];
    }


    public function setORDER_MINIMUM($value) {
        $this->array = array_merge ($this->array,array(
            'ORDER_MINIMUM' => $value));
    }
    public function getORDER_MINIMUM(){

        return $this->array ['ORDER_MINIMUM'];
    }


    public function setFOOD_TAG_ID($value) {
        $this->array = array_merge ($this->array,array(
            'FOOD_TAG_ID' => $value));
    }
    public function getFOOD_TAG_ID(){

        return $this->array ['FOOD_TAG_ID'];
    }


    public function setDESCRIPTION($value) {
        $this->array = array_merge ($this->array,array(
            'DESCRIPTION' => $value));
    }
    public function getDESCRIPTION(){

        return $this->array ['DESCRIPTION'];
    }


    public function setDISPLAY_ORDER($value) {
        $this->array = array_merge ($this->array,array(
            'DISPLAY_ORDER' => $value));
    }
    public function getDISPLAY_ORDER(){

        return $this->array ['DISPLAY_ORDER'];
    }


    public function setCREATED_ON($value) {
        $this->array = array_merge ($this->array,array(
            'CREATED_ON' => $value));
    }
    public function getCREATED_ON(){

        return $this->array ['CREATED_ON'];
    }


    public function setCREATED_BY($value) {
        $this->array = array_merge ($this->array,array(
            'CREATED_BY' => $value));
    }
    public function getCREATED_BY(){

        return $this->array ['CREATED_BY'];
    }


    public function setUPDATED_ON($value) {
        $this->array = array_merge ($this->array,array(
            'UPDATED_ON' => $value));
    }
    public function getUPDATED_ON(){

        return $this->array ['UPDATED_ON'];
    }


    public function setUPDATED_BY($value) {
        $this->array = array_merge ($this->array,array(
            'UPDATED_BY' => $value));
    }
    public function getUPDATED_BY(){

        return $this->array ['UPDATED_BY'];
    }


    public function toInsertCSV() {
        $str="";

        // FOOD_ID
        $str .= self::getFOOD_ID().",";
        // RESTAURANT_ID
        $str .= "'". self::getRESTAURANT_ID()."',";

        // FOOD_GROUP_ID
        $str .= "'". self::getFOOD_GROUP_ID()."',";

        // FOOD_TAG_ID
        $str .= "'". self::getFOOD_TAG_ID()."',";

        // FOOD_NAME
        $str .= "'". self::getFOOD_NAME()."',";

        // DESCRIPTION
        $str .= "'". self::getDESCRIPTION()."',";

        // IMG_URL
        $str .= "'". self::getIMG_URL()."',";
        // FOOD_PRICE
        $str .= "'". self::getFOOD_PRICE()."',";
        // IS_LIMIT
        $str .= "'". self::getIS_LIMIT()."',";
        // LUNCHBOX_AMOUNTS
        $str .= "'". self::getLUNCHBOX_AMOUNTS()."',";
        // LUNCHBOX_PRICE
        $str .= "'". self::getLUNCHBOX_PRICE()."',";
        // IS_ON_SELL
        $str .= "'". self::getIS_ON_SELL()."',";
        // STOCK_DAY
        $str .= "'". self::getSTOCK_DAY()."',";
        // STOCK_LEFT
        $str .= "'". self::getSTOCK_LEFT()."',";
        // SPECIAL_FEATURE
        $str .= "'". self::getSPECIAL_FEATURE()."',";
        // ORDER_UNIT
        $str .= "'". self::getORDER_UNIT()."',";
        // ORDER_MINIMUM
        $str .= "'". self::getORDER_MINIMUM()."',";


        // DISPLAY_ORDER
        $str .= "'". self::getDISPLAY_ORDER()."',";
        // CREATED_ON
        $str .= "now()" . ",";

        // CREATED_BY
        $str .= "'". self::getCREATED_BY()."',";
        // UPDATED_ON
        $str .= "now()" . ",";

        // UPDATED_BY
        $str .= "'". self::getUPDATED_BY() . "'";
        return $str;
    }



    public function toUpdateSet() {
        $str="";

        // RESTAURANT_ID
        $str.= '`RESTAURANT_ID` = "' . self::getRESTAURANT_ID() . '",';

        // FOOD_GROUP_ID
        $str.= '`FOOD_GROUP_ID` = "' . self::getFOOD_GROUP_ID() . '",';

        // FOOD_NAME
        $str.= '`FOOD_NAME` = "' . self::getFOOD_NAME() . '",';

        // IMG_URL
        $str.= '`IMG_URL` = "' . self::getIMG_URL() . '",';

        // FOOD_PRICE
        $str.= '`FOOD_PRICE` = "' . self::getFOOD_PRICE() . '",';

        // IS_LIMIT
        $str.= '`IS_LIMIT` = "' . self::getIS_LIMIT() . '",';

        // LUNCHBOX_AMOUNTS
        $str.= '`LUNCHBOX_AMOUNTS` = "' . self::getLUNCHBOX_AMOUNTS() . '",';

        // LUNCHBOX_PRICE
        $str.= '`LUNCHBOX_PRICE` = "' . self::getLUNCHBOX_PRICE() . '",';

        // IS_ON_SELL
        $str.= '`IS_ON_SELL` = "' . self::getIS_ON_SELL() . '",';

        // STOCK_DAY
        $str.= '`STOCK_DAY` = "' . self::getSTOCK_DAY() . '",';

        // STOCK_LEFT
        $str.= '`STOCK_LEFT` = "' . self::getSTOCK_LEFT() . '",';

        // SPECIAL_FEATURE
        $str.= '`SPECIAL_FEATURE` = "' . self::getSPECIAL_FEATURE() . '",';

        // ORDER_UNIT
        $str.= '`ORDER_UNIT` = "' . self::getORDER_UNIT() . '",';

        // ORDER_MINIMUM
        $str.= '`ORDER_MINIMUM` = "' . self::getORDER_MINIMUM() . '",';

        // FOOD_PROPERTY
        $str.= '`FOOD_TAG_ID` = "' . self::getFOOD_TAG_ID() . '",';

        // DESCRIPTION
        $str.= '`DESCRIPTION` = "' . self::getDESCRIPTION() . '",';

        // DISPLAY_ORDER
        $str.= '`DISPLAY_ORDER` = "' . self::getDISPLAY_ORDER() . '",';

        // CREATED_ON
        $str.= '`CREATED_ON` = "' . self::getCREATED_ON() . '",';

        // CREATED_BY
        $str.= '`CREATED_BY` = "' . self::getCREATED_BY() . '",';

        // UPDATED_ON
        $str .= "UPDATED_ON = now()," ;

        // UPDATED_BY
        $str.= '`UPDATED_BY` = "' . self::getUPDATED_BY() . '"';
        return $str;
    }



    public function toUpdateWhere(){
        $str = "";
        $str .= "`FOOD_ID` = '" . self::getFOOD_ID()."'";
        return $str;
    }

}